package cn.itsource.ymcc.factory;

import cn.itsource.ymcc.feignclient.CourseFeignClient;
import cn.itsource.ymcc.feignclient.CourseMarketFileFeignClient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

@Component
@Slf4j
public class CourseFallbackFactory implements FallbackFactory<CourseFeignClient> {

    @Override
    public CourseFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new CourseFeignClient() {
            @Override
            public JSONResult getCourseforuser(Long courseId,Long loginId) {
                log.info("查询课程购买信息，异常");
                return JSONResult.error(courseId+","+loginId+",查询失败！");
            }

            @Override
            public JSONResult getOrderDetail(String courseIds) {
                log.info("查询课程Order信息，异常");
                return JSONResult.error(courseIds+"查询失败！");
            }

            @Override
            public JSONResult getDetail(Long courseId) {
                log.info("查询课程Detail信息，异常");
                return JSONResult.error(courseId+"查询失败！");
            }
        };
    }
}
